package com.hzgj.bcl.soa.cicada.sender;

import com.hzgj.bcl.soa.cicada.AsyncHandler;
import com.hzgj.bcl.soa.cicada.Lifecycle;
import com.hzgj.bcl.soa.cicada.ListenableFuture;
import com.hzgj.bcl.soa.rpc.IpAddress;
import com.hzgj.bcl.soa.rpc.message.Message;

import java.io.IOException;

/**
 * Created by warning5 on 2017/3/3.
 */
public interface Sender extends Lifecycle {

    <T> ListenableFuture<T> send(final Message message, final AsyncHandler<T> asyncHandler, long requestTimeoutInMs, String poolKey) throws IOException;

    void setStatus(Status status);

    IpAddress getIpAddress();

    boolean isClose();

    enum Status {
        SUSPEND, OK, INVALIDATE, CLOSED;
    }
}
